package com.tms.user.controller;

import com.tms.common.Result;
import com.tms.user.bean.User;
import com.tms.user.dto.UserLoginByUserNameDTO;
import com.tms.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Author：潘建冰
 * Package：com.tms.user.controller
 * Project：TaskManageSystem
 * name：UserController
 * Date：2025/3/24  20:50
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/get")
    public Result<List<User>> getAll(){
        return Result.success(userService.list());
    }

    /**
     * 根据用户名密码登录
     * @param userLoginByUserNameDTO 登录DTO
     * @return Result
     */
    @PostMapping("/loginByUserName")
    public Result<Map<String,Object>> login(@RequestBody UserLoginByUserNameDTO userLoginByUserNameDTO){
        return Result.success(userService.loginByUserName(userLoginByUserNameDTO));
    }
}
